# (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
# All rights reserved.  The file named COPYRIGHT specifies the terms 
# and conditions for redistribution.

#
# $Id$
#
# Based on Library makefile template: *Revision: 1.15 *
#

NAME			= str
VPATH			= @srcdir@
SRCDIR			= @srcdir@

HEADERS			= str.h strparse.h
SOURCES			= strutil.c strprint.c strparse.c
OBJECTS			= strutil.o strprint.o strparse.o

MANFILES		= $(SRCDIR)/strparse.3 $(SRCDIR)/strprint.3 \
			$(SRCDIR)/strutil.3
INCLUDEFILES		= $(SRCDIR)/str.h

# The following variables are used by the 'install' entry and
# should be customized:
#     LIBDIR:     where the library will be placed
#     INCUDEDIR:  where the include files will be placed
#     MANDIR:     where the man pages will be placed
LIBDIR			= ../../lib
MANDIR			= ../../man
INCLUDEDIR		= ../../include

#
# Available flags
#	NBIC	: number of bits in a character variable (defaults to 8)
#	WIDE_INT : widest integer supported by the CPU/compiler
#			  (defaults to 'long')
#	WIDE_INT_SIZE  : size of the WIDE_INT type in bits (defaults to 32);
#		  effective (and required) only when WIDE_INT is defined
#	NO_SIO	: if the SIO library is not available (results in turning
#			  all the string printing functions to no-ops)
#
DEBUG			= -g		# -g or -O

CPP_DEFS		= 

#
# The following variables shouldn't need to be changed
#
CPP_FLAGS		= $(CPP_DEFS) -I$(INCLUDEDIR)
CC_FLAGS		= $(DEBUG)
CFLAGS			= @CFLAGS@ $(CPP_FLAGS) $(CC_FLAGS)

INSTALL			= @INSTALL@
FMODE			= -m 640			# used by install
RANLIB			= @RANLIB@

LIBNAME			= lib$(NAME).a

lib: $(LIBNAME)

libopt: clean
	make DEBUG=-O "DEFS=$(DEFS)" lib
	$(INSTALL) $(FMODE) $(LIBNAME) $(LIBDIR)-O

$(LIBNAME): $(OBJECTS)
	ar r $@ $?
	$(RANLIB) $@

LINT_IGNORE=possible pointer alignment|RCSid unused

install: $(LIBNAME)
	@if test "$(LIBDIR)" -a "$(INCLUDEDIR)" -a "$(MANDIR)" ;\
	then \
		$(INSTALL) $(FMODE) $(LIBNAME) $(LIBDIR) ;\
		$(RANLIB) $(LIBDIR)/$(LIBNAME) ;\
		echo "Installed $(LIBNAME) to $(LIBDIR)" ;\
		for i in $(INCLUDEFILES); do $(INSTALL) $(FMODE) $$i $(INCLUDEDIR) ; done ;\
		echo Installed $(INCLUDEFILES) to $(INCLUDEDIR) ;\
		for i in $(MANFILES) ; do $(INSTALL) $(FMODE) $$i $(MANDIR) ; done ;\
		echo Installed $(MANFILES) to $(MANDIR) ;\
	else \
		echo "You forgot to set one of the following variables: LIBDIR,INCLUDEDIR,MANDIR" ;\
	fi

uninstall:
	a=`pwd` ; cd $(INCLUDEDIR) ;\
	if test $$a != `pwd` ; then rm -f $(INCLUDEFILES) ; fi
	a=`pwd` ; cd $(LIBDIR) ;\
	if test $$a != `pwd` ; then rm -f $(LIBNAME) ; fi
	a=`pwd` ; cd $(MANDIR) ;\
	if test $$a != `pwd` ; then rm -f $(MANFILES) ; fi

clean:
	rm -f $(OBJECTS) $(LIBNAME) core
	rm -f *.swp
	rm -f *.?~ 

spotless: clean uninstall

distclean: clean
	rm -f Makefile

#
# PUT HERE THE RULES TO MAKE THE OBJECT FILES
#
strparse.o:		strparse.h str.h
strprint.o:		str.h
strutil.o:		str.h

